package com.ay277.htqoa.base.biz;

import com.ay277.htqoa.base.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * Created by accp09 on 2016/12/7.
 */
@Service
@Transactional
public abstract class BaseBiz<E extends Serializable,PK extends Serializable> {
    private Dao<E,PK> dao;
    public Dao<E, PK> getDao() {
        return dao;
    }
    @Autowired
    public void setDao(Dao<E, PK> dao) {
        this.dao = dao;
    }
    public void doSave(E entity){
        dao.save(entity);
    }
    public void doUpdate(E entity){
        dao.update(entity);
    }
    public void doDelete(E entity){
        dao.delete(entity);
    }
    public E findById(PK id){
        return dao.get(id);
    }
    public List<E> findAll(){
        return dao.list();
    }



}


